<template>
  <div class="l_top">


    <span tag="span" v-if="school" @click="showLocallist=true"><i class="iconfont icon-dingwei"></i><i style="font-size:0.3rem">{{school}}</i><i class="iconfont icon-you"></i></span>
    <span v-else><i class="iconfont icon-dingwei"></i>定位中...</span>
    <!-- <span class="sel">
      <v-select v-model="local" :options="ziti"></v-select>
    </span> -->
    <mt-popup
      v-model="showLocallist"
      popupTransition="popup-fade"
    >
      <mt-radio
        title="可选地址"
        v-model="school"
        :options="dizhi"
      >
      </mt-radio>
    </mt-popup>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ts: this.newStore(),
      school: '',
      showLocallist: false,
      local: '',
      locationData: {},
      ziti: [],
      dizhi: [],
      schoollist: {},
      schoollist2: {},
    };
  },
  created() {
    this.getLocation();
  },
  watch: {
    school() {
      // this.getZtlist();
      this.$emit('getschool', this.schoollist[this.school], this.school);
      this.showLocallist = false;
    },
    // local() {
    //   this.$emit('getlocal', this.schoollist2[this.local]);
    // },
  },
  methods: {
    getLocation() {
      const req = {
        handle: '1E8254760FECAC00839BD73D1C4F9A6559B7AE69B5ABEA2D2D2C5C3C3BF5C3224EB425F14597A3B6',
        lng: '13.3',
        lat: '20.8',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.locationData = ts.d.data;
        for (let i = 0; i < this.locationData.operation1.length; i += 1) {
          this.dizhi.push(this.locationData.operation1[i].hash.schoolname);

          this.schoollist[this.locationData.operation1[i].hash.schoolname] = this.locationData.operation1[i].hash.schoolid;
        }
        this.school = this.dizhi[1];
        // this.getZtlist();
      });
    },
  },
};
</script>

<style lang="stylus">
.mint-radio-label
  color #26a2ff
.mint-popup
  width 80%
.v-select.searchable .dropdown-toggle
  background #fff

.l_top
  height 1rem
  line-height 1rem
  background #26a2ff
  color #fff
  padding-left 0.2rem
  position fixed
  width 100%
  z-index 20
  i
    font-size 0.3rem
    float left
</style>

